package com.sitech.ibnms.util.charts.fusion;

import java.util.List;

/**
 * 
 * @author Mirror_Jean
 *
 */
public class FusionHBulletChart{

	
	
	public String getXML(FusionHBulletChartParameter parameter){
		String str = "<chart palette='"+parameter.getPalette()+"' formatNumberScale='"+parameter.getFormatNuberScale()+"'" +
				" lowerLimit='"+parameter.getLowerLimit()+"'" +
				" majorTMNumber='"+parameter.getMajorTMNumber()+"'" +
				" showValue='"+parameter.getShowValue()+"'" +
				" upperLimit='"+parameter.getUpperLimit()+"' " +
				" caption='"+parameter.getCaption()+"' " +
				" subcaption='"+parameter.getSubCaption()+"'" +
				" chartTopMargin='"+parameter.getChartTopMargin()+"' " +
				" chartLeftMargin='"+parameter.getChartLeftMargin()+"'"+
				"  chartRightMargin='"+parameter.getChartRightMargin()+"'" +
				" chartBottomMargin='"+parameter.getChartBottomMargin()+"'"+
				" roundRadius='"+parameter.getRoundRadius()+"'" +
				" colorRangeFillMix='"+parameter.getColorRangeFillMix()+"'" +
				" showTickMarks='"+parameter.getShowTickMaret()+"'"+
				" showTickValues='"+parameter.getShowTickValues()+"'"+
				" showBorder='0'"+
				" plotFillPercent='"+parameter.getPlotFillPercent()+"'" +
				" targetFillPercent='"+parameter.getTargetFillPercent()+"'"+
				" targetThickness= '"+parameter.getTargetThickness()+"'"+
				" plotFillColor='"+parameter.getPlotFillColor()+"'"+
				" targetColor='"+parameter.getTargetColor()+"'"+
				" numberSuffix='"+parameter.getNumberSuffix()+"'"+
				" numberPrefix='"+parameter.getNumberPrefix()+"'"+
				  //���ñ�Ե
				" showColorRangeBorder='"+parameter.getShowColorRangeBorder()+"'"+        
				" colorRangeBorderColor='"+parameter.getColorRangeBorderColor()+"'"+
				" colorRangeBorderThickness='"+parameter.getColorRangeBorderThickness()+"'"+
				" colorRangeBorderAlpha='"+parameter.getColorRangeBorderAlpha()+"'"+
				" showShadow='"+parameter.getShowShadow()+"'"+
				" colorRangeFillRatio='"+parameter.getColorRangeFillRatio()+"'>";
		str += this.getColorRange(parameter);
		str += "<value>"+(int)parameter.getValue()+"</value>";
		str += " <target>"+(int)parameter.getTarget()+"</target>";
		str += "</chart>";
		return str;
	}
	
	public String getColorRange(FusionHBulletChartParameter parameter){
		
		StringBuffer strBuffer = new StringBuffer();
		List colorRangeList = parameter.getList();
		int size = colorRangeList.size();
		System.out.println("rangeColor size :"+size);
		if(size > 0){
			strBuffer.append("<colorRange>");
			for(int index =0 ; index < size ; index ++){
				ColorRange colorRange = (ColorRange) parameter.getList().get(index);
				if(parameter.getValue() > colorRange.getMinValue() && parameter.getValue() < colorRange.getMaxValue()){
					strBuffer.append(" <color minValue='"+colorRange.getMinValue()+"' maxValue='"+colorRange.getMaxValue()+"' />");
				}
			}
			strBuffer.append("</colorRange>");
		}else{
			return "<colorRange><color minValue='0' maxValue='"+(int)parameter.getValue()+"' /></colorRange>";
		}
		return strBuffer.toString();
	}
	
	public String getHBulletChart(FusionHBulletChartParameter parameter){
		return FusionChartCommon.getScript(parameter)
				.replaceAll("######", this.getXML(parameter));
	}
}
